import { defineStore } from 'pinia';
import { getSiteBrandDetail } from '/@/api/sys';

export const useSystemStore = defineStore('system', {
  state: () => ({
    langList: ['zh_CN', 'en_US', 'pt_BR', 'th_TH', 'vi_VN', 'hi_IN'],
  }),
  actions: {
    async getValidLangList(): Promise<any> {
      try {
        const res = await getSiteBrandDetail({ tag: 'base' });
        if (!res.lang) return;
        if (res.lang.f == 2) {
          return this.langList;
        }
        if (res.lang.f == 1) {
          return res.lang.d;
        }
        return;
      } catch (e) {
        console.log(e);
      }
    },
  },
});
